# -*- coding: UTF-8 -*-

import xml.etree.ElementTree as ET

HAUT = 'HAUT'
BAS = 'BAS'
GAUCHE = 'GAUCHE'
DROITE = 'DROITE'

class Chanson:
    def __init__(self, duree, cheminMP3, moves):
        self.duree = duree
        self.chemin = cheminMP3
        self.moves = moves
    
    def readChanson(cheminXML):
        arbre = ET.ElementTree()
        arbre.parse(cheminXML)
        
        #CheminMP3
        el = arbre.find('MP3')
        cheminMP3 = el.text;

        #Durée
        el = arbre.find('Duree')
        duree = float(el.text);

        #Liste des moves.
        liste=arbre.find('Moves').findall("Move")
        moves = []

        for i in liste:
            interval = i.get('interval',None)
            if interval:
                moves.append(MoveDeDance(float(i.get('temps')), i.get('direction'), float(interval)))
            else:
                moves.append(MoveDeDance(float(i.get('temps')), i.get('direction')))

        return Chanson(duree, cheminMP3, moves)
    readChanson = staticmethod(readChanson)

    def getScore(self):
        #WTH is that?
        pass

class MoveDeDance:
    def __init__(self, temps, touche, interval = 0.75):
        """ Interval en ms """
        self.temps = temps
        self.touche = touche
        self.interval = interval